<!--
 * @Author: your name
 * @Date: 2022-01-06 19:26:34
 * @LastEditTime: 2022-01-15 17:27:40
 * @LastEditors: Please set LastEditors
 * @Description: 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 * @FilePath: \vue_test\src\components\About.vue
-->
<template>
  <h2>我是About的内容</h2>
</template>

<script>
export default {
  name: "About",
  /* beforeDestroy() {
    console.log("About组件即将被销毁了！");
  },
  */
  mounted() {
    console.log("%%%", this.$route);
  },
  //当路由进入后：通过路由规则，进入该组件时被调用
  beforeRouteEnter(to, from, next) {
    console.log("About---beforeRouteEnter", to, from);
    if (to.meta.isAuth) {
      if (localStorage.getItem("school") === "atguigu") {
        next();
      } else {
        alert("学校名不对，无权限查看！");
      }
    } else {
      next();
    }
  },
  //当路由离开时：通过路由规则，离开该组件时被调用
  beforeRouteLeave(to, from, next) {
    console.log("About---beforeRouteLeave", to, from);
    next();
  },
};
</script>
